#include"CollisionModel.h"

/////////////////
//include
/////////////////
#include"ANX.h"
#include"Layout.h"
#include"Device.h"
#include"DeviceContext.h"
#include"ContentManager.h"
/////////////////
//prottype
/////////////////

/////////////////
//const
/////////////////



CollisionModel::CollisionModel()
{
	
}
CollisionModel::~CollisionModel()
{
}
void CollisionModel::CreateBuffer(Device* device)
{
	vertex_buffer	= device->CreateVertexBuffer(vertex.Front(),vertex.GetSize(),sizeof(Vector3D));
	matrix_buffer	= device->CreateConstantBuffer(&XMMatrixIdentity(),sizeof(XMMATRIX));
}
void CollisionModel::CreateShader(Device* device)
{
	D3D11_INPUT_ELEMENT_DESC input_element[1] = 
	{
		Layout::Get()->GetElement("POSITION"),
	};
	 ContentManager::LoadShader("a.fx","WireVS","WirePS",input_element,1);
}
void CollisionModel::Draw(DeviceContext* device_context)
{
	device_context->SetVertexBuffer(vertex_buffer,sizeof(Vector3D),0);
	device_context->SetTopology(D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP);
	shader->Set(device_context);

	Matrix tmp =  (
		scale_mat	*
		pos_mat		*
		(-pos_mat)	* 
		rot_mat		*
		pos_mat).Transpose().Xm();

	device_context->UpdateBuffer(matrix_buffer,&tmp,sizeof(Matrix));
	device_context->SetConstantBuffer(matrix_buffer,2);
	device_context->Draw(vertex.GetSize(),0);
}
